<?php

class McCube_Html_Listing_FilterBox{

    protected $_filters = array();

    /** */
    public function __construct($listing){
        $this->_listing = $listing;
    }

    public function setFilter($name, McCube_Html_Listing_Column $filter){
        $this->_filters[$name] = $filter;
        return $this;
    }

    public function render(){
        $echo = '';
        foreach($this->_filters as $key=>$filter){
            $echo .= $this->_listing->getJsListing().'.setColumn("'.$key.'",'.json_encode($filter->getConfig()).');'."\n";
        }

        return '<script type="text/javascript">'
            .$echo
        .'</script>';
    }
}